$(function() {
	function u() {
		var e = $(window).width(),
			t = e % 2 == 0 ? 0 : 1;
		$(".ie_p2").width(e + t)
	}

	function a() {
		function r() {
			var e = "brwser_skin_";
			for (var i = 1; i < 6; i++) $("." + e + i).fadeOut(600), i !== 0 && $("#skin_" + i).removeClass("active");
			$("." + e + t).fadeIn(600), $("#skin_" + t).addClass("active"), t++, t > 5 && (t = 1), n && clearTimeout(n), n = setTimeout(r, 3e3)
		}

		function s() {
			var e = $(".page_3"),
				t = $(window).height(),
				n = 0;
			t < 850, i = i || e.offset().top - n, $(window).scrollTop() >= i && (A || O())
		}

		function m() {
			var e = $(window).scrollTop();
			a.css("position") != "fixed" && e < d && e > c && (a.css({
				position: "fixed",
				top: h
			}), $(".btab").stop(!0, !0).fadeIn(), $(".bwave").css({
				opacity: 0,
				display: "none"
			}), $(".defskin").removeClass("changebg"), clearTimeout(n), $(".brwser_skin").hide(), $(".defskin").show());
			var t = (e - p) * (v / l),
				r = 1 - (e - p) * (1 / l),
				i = (e - p) * (.08 / l),
				s = (e - p) * (41 / l),
				o = (e - p) * (49 / l),
				u = .75 - (e - p) * (.75 / l);
			if (t > v || e >= d) t = v, r = 0, i = .08, s = 39, o = 49, u = 0, a.css("position") != "absolute" && a.css({
				position: "absolute",
				top: p + l - $(".page_1").offset().top + h
			}), $(".btab").stop(!0, !0).fadeOut(), $(".bwave").css({
				opacity: 1,
				display: "block"
			}), $(".defskin").addClass("changebg");
			if (t < 0 || e <= c) t = 0, r = 1, i = 0, s = 0, o = 0, u = .75, a.css("position") == "fixed" && a.css({
				position: "static",
				top: 0
			});
			e > 632 ? $(".tilmask").hide() : $(".tilmask").show(), a.find(".brwser").css({
				transform: "perspective(875px) rotateX(" + (v - t) + "deg)"
			}), $(".wmask").css("opacity", r), $(".btab").css({
				transform: "scale(" + (1 - i) + ")",
				top: 47 - s,
				"margin-left": -(o + 373)
			}), $(".browser_bg").css("opacity", 1 - r)
		}

		function C() {
			function f(t, n) {
				var r = 0,
					i = 600,
					s = t - (e - x - r) * (t / i);
				return n && (s = (e - x - r) * (t / i)), s > t && (s = t), s < 0 && (s = 0), s
			}

			function l(t, n) {
				var r = 600,
					i = 600,
					s = t - (e - x - r) * (t / i);
				return n && (s = (e - x - r) * (t / i)), s > t && (s = t), s < 0 && (s = 0), s
			}
			var e = $(window).scrollTop();
			g.css("position") != "fixed" && e < T && e > E && (g.css({
				position: "fixed",
				top: S
			}), $(".ambg").css("opacity", 0));
			var t = (e - x) * (N / w),
				n = (e - x) * (50 / w),
				r = (e - x) * (95 / w),
				i = 1 - (e - x) * (1 / w),
				s = (e - x) * (.08 / w),
				o = (e - x) * (39 / w),
				u = (e - x) * (49 / w),
				a = .75 - (e - x) * (.75 / w);
			if (t > N || e >= T) t = N, n = 50, i = 0, s = .08, o = 39, u = 49, a = 0, g.css("position") != "absolute" && g.css({
				position: "absolute",
				top: x + w - $(".page_2").offset().top + S + S
			}), $(".btab").stop(!0, !0).fadeOut(), $(".ambg").css("opacity", 1);
			if (t < 0 || e <= E) t = 0, n = 0, i = 1, s = 0, o = 0, u = 0, a = .75, g.css("position") == "fixed" && g.css({
				position: "static",
				top: 0
			});
			r > 95 && (r = 95), r < 0 && (r = 0), g.find(".file_sh").css({
				transform: "perspective(900px) translate(-" + f(160) + "px," + -f(2) + "px) rotateY(" + -(50 + f(36)) + "deg)"
			}), g.find(".file_pic").css({
				transform: "perspective(900px) translate(-" + f(243) + "px," + f(16) + "px) rotateY(" + -(50 + f(38)) + "deg)"
			}), g.find(".file_ct").css({
				transform: "perspective(900px) translate(-" + f(315) + "px," + -f(44) + "px) rotateY(" + -(50 + f(38)) + "deg)"
			}), e > E + 600 ? (g.find(".computer").css({
				transform: "perspective(2000px) rotateY(" + (N - l(N, 1)) + "deg)"
			}), g.find(".phone").css({
				transform: "perspective(900px) rotateY(" + -(50 - l(50, 1)) + "deg)"
			}), l(50, 1) > 15 ? $(".inerphone").hide() : $(".inerphone").show(), g.find(".file_sh,.file_pic,.file_ct").css({
				transform: "perspective(900px) rotateY(" + -l(50) + "deg)"
			}), $(".cpbomside").css({
				transform: "translate(0," + l(5, 1) + "px) scale(" + (1 - l(8, 1) * .1) + ")"
			})) : g.find(".computer,.phone,.cpbomside").attr("style", "")
		}

		function k() {
			var e = $(".wavewarp");
			e.scrollLeft(e.scrollLeft() + 1), setTimeout(k, 200)
		}

		function L() {
			$(".page_1").addClass("animate")
		}

		function O() {
			A++, $(".point").css({
				transform: "rotate(" + A + "deg)"
			}), A < 360 && (M(".virus_1", 12), M(".virus_2", 63), M(".virus_3", 80), M(".virus_4", 123), M(".virus_5", 300), M(".virus_6", 245), M(".virus_7", 180)), setTimeout(O, 15)
		}

		function M(e, t) {
			if (A % 360 != t) return;
			$(e).addClass("virusAm")
		}

		function P(e) {
			this.opt = e || {}, this.K = 1, this.F = 15, this.speed = this.opt.speed || .1, this.noise = this.opt.noise || 30, this.phase = this.opt.phase || 0, window.devicePixelRatio || (devicePixelRatio = 1), this.width = devicePixelRatio * (this.opt.width || 320), this.height = devicePixelRatio * (this.opt.height || 100), this.MAX = this.height / 2 - 4, this.canvas = $("#wave")[0], this.canvas.width = this.width, this.canvas.height = this.height, this.canvas.style.width = this.width / devicePixelRatio + "px", this.canvas.style.height = this.height / devicePixelRatio + "px", this.ctx = this.canvas.getContext("2d"), this.run = !1
		}

		function B() {
			var e = $(window).width(),
				t = Math.ceil(e * (148 / 1903)),
				n = Math.ceil(t / 2 - 74),
				r = $("#hill")[0],
				i = r.getContext("2d");
			$(".content").css("top", -292 - n), r.width = e, r.height = t, i.beginPath(), i.moveTo(0, 0), i.lineTo(e, 0), i.lineTo(0, t), i.fillStyle = "rgba(67,215,157,1)", i.fill()
		}
		u();
		if ($.browser.msie && parseInt($.browser.version) < 10) return;
		var e = !1,
			t = 1,
			n;
		$(document).on("mousewheel", function(t, n, r, i) {
			if (e) return !1;
			var s = $(window).scrollTop(),
				o = $(window).height();
			n < 0 && (s < 958 && (o < 580 ? $("html,body").animate({
				scrollTop: "958px"
			}, 2550, function() {
				e = !1, $(".allwave,.hands").fadeIn()
			}) : $("html,body").animate({
				scrollTop: "1052px"
			}, 2550, function() {
				e = !1, $(".allwave,.hands").fadeIn()
			}), e = !0), s < 1764 && s >= 958 && (o < 580 ? $("html,body").animate({
				scrollTop: $(".page_2").offset().top + "px" || "1764px"
			}, 800, function() {
				e = !1
			}) : $("html,body").animate({
				scrollTop: $(".page_2").offset().top + "px" || "1858px"
			}, 800, function() {
				e = !1
			}), e = !0), s < 2656 && s >= 1744 && (o < 580 ? $("html,body").animate({
				scrollTop: $(".page_3").offset().top + "px" || "2656px"
			}, 800, function() {
				e = !1
			}) : $("html,body").animate({
				scrollTop: $(".page_3").offset().top + "px" || "2750px"
			}, 800, function() {
				e = !1
			}), e = !0), s < 3815 && s > 2656 && (o < 580 ? $("html,body").animate({
				scrollTop: $(".page_4").offset().top + "px" || "3815px"
			}, 800, function() {
				e = !1
			}) : $("html,body").animate({
				scrollTop: $(".page_4").offset().top + "px" || "3899px"
			}, 800, function() {
				e = !1
			}), e = !0))
		}), $(document).on("scroll", function(e) {
			var r = $(window).scrollTop(),
				i = $(window).height();
			r + 250 >= $(".page_1").offset().top && ($(".page_1").hasClass("addAnimation") || (clearTimeout(n), $(".titleAnim2,.titleAnim3").animate({
				opacity: 0
			}, 500)), $(".page_1").addClass("addAnimation")), r + 250 < $(".page_1").offset().top && ($(".page_1").hasClass("addAnimation") && $(".titleAnim2,.titleAnim3").delay(500).animate({
				opacity: 1
			}, 500), $(".page_1").removeClass("addAnimation"), $(".allwave,.hands").hide(), clearTimeout(n), t = 1, $(".skin").removeClass("active"), $(".brwser_skin").hide(), $(".defskin").show()), r >= $(".page_2").offset().top - 100 && $(".page_2").addClass("addAnimation"), r < $(".page_2").offset().top - $(window).height() / 2 && $(".page_2").removeClass("addAnimation"), r >= $(".page_3").offset().top - 100 && $(".page_3").addClass("addAnimation"), r < $(".page_3").offset().top - $(window).height() / 2 && $(".page_3").removeClass("addAnimation"), (r >= $(".lastwrap").offset().top || $(".footer").offset().top <= r + i) && $(".p4ct").addClass("floatAm"), r < $(".p4ct").offset().top - $(window).height() / 2 && $(".p4ct").removeClass("floatAm")
		}), $(".skin").mouseenter(function() {
			$(".hands,.defskin").hide(), $(".brwser_skin,.skin").removeClass("active"), $(".brwser_skin").stop(!0, !0).fadeOut(250), $(".brwser_" + this.id).addClass("active").stop(!0, !0).fadeIn(250), $(this).addClass("active"), t = this.id.split("_")[1], clearTimeout(n), $(".page_1").data("mouseleave", !0)
		}), $(".skin").mouseleave(function() {
			clearTimeout(n), t >= 5 ? t = 1 : t++;
			if (!$(".page_1").data("mouseleave")) return !1;
			n = setTimeout(r, 2500), $(".page_1").data("mouseleave", !1)
		});
		var i, a = $(".bwrap"),
			f = a.offset().top,
			l = 650,
			c = f - $(window).height() / 3,
			h = f - c,
			p = f - h,
			d = c + l,
			v = 25,
			g = $(".fixbg"),
			y = $(window).height(),
			b = g.offset().top,
			w = 1200,
			E = b,
			S = y > 680 ? b - E : -120,
			x = b - S,
			T = E + w,
			N = 55;
		L();
		var A = 0,
			_, D;
		window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function(e, t) {
			_ = setTimeout(e, t || 1)
		}, window.cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.msCancelAnimationFrame || function(e) {
			_ = clearTimeout(e)
		}, P.prototype = {
			_globalAttenuationFn: function(e) {
				return Math.pow(this.K * 4 / (this.K * 4 + Math.pow(e, 4)), this.K * 2)
			},
			_drawLine: function(e, t, n, r, i) {
				this.ctx.moveTo(0, 0), this.ctx.beginPath(), this.ctx.strokeStyle = t, this.ctx.lineWidth = n || 1;
				var s, o;
				i = i || this.F, r = r * this.MAX || this.noise;
				for (var u = -this.K; u <= this.K; u += .01) u = parseFloat(parseFloat(u).toFixed(2)), s = this.width * ((u + this.K) / (this.K * 2)), o = this.height / 2 + r * Math.pow(Math.sin(u * 10 * e), 1) * Math.sin(i * u - this.phase), this.ctx.lineTo(s, o);
				this.ctx.lineTo(this.width, this.height), this.ctx.lineTo(0, this.height), this.ctx.fillStyle = t, this.ctx.fill()
			},
			_clear: function() {
				this.ctx.globalCompositeOperation = "destination-out", this.ctx.fillRect(0, 0, this.width, this.height), this.ctx.globalCompositeOperation = "source-over"
			},
			_draw: function() {
				if (!this.run) return;
				this.phase = (this.phase + this.speed) % (Math.PI * 64), this._clear(), this._drawLine(.5, "rgba(120,255,212,0.5)", 1, .35, 6), this._drawLine(1, "rgba(0,188,62,0.5)", 1, .25, 6), clearAnimationFrame = requestAnimationFrame(this._draw.bind(this), 1e3)
			},
			start: function() {
				this.phase = 0, this.run = !0, this._draw()
			},
			stop: function() {
				this.run = !1, this._clear()
			},
			setNoise: function(e) {
				this.noise = Math.min(e, 1) * this.MAX
			},
			setSpeed: function(e) {
				this.speed = e
			},
			set: function(e, t) {
				this.setNoise(e), this.setSpeed(t)
			},
			bl: function(e) {
				return 128
			}
		};
		var H = new P({
			width: $(window).width(),
			height: 200,
			container: $(".wavewarp")[1]
		});
		H.setSpeed(.01), H.start(), o.SiriWave = P, B(), o.canvasSty = B
	}

	function f(e, t) {
		var n = null,
			r = this;
		return function() {
			n || (n = setTimeout(function() {
				clearTimeout(n), n = null, e.apply(r)
			}, t || 500))
		}
	}
	var e = navigator.userAgent,
		t = /Chrome\/[0-9]{2}/g;
	if (e.search(t) > 0) {
		var n = t.exec(e)[0],
			r = n.split("/"),
			i = r[1],
			s = "chrome" + i;
		$("html").addClass(s)
	}
	var o = {};
	$("body").animate({
		scrollTop: 0
	}, 0), a(), $(window).resize(f(function() {
		u();
		if ($.browser.msie && parseInt($.browser.version) < 10) return;
		cancelAnimationFrame(clearAnimationFrame);
		var e = new o.SiriWave({
			width: $(window).width(),
			height: 200,
			container: $(".wavewarp")[1]
		});
		e.setSpeed(.01), e.start(), o.canvasSty()
	}, 100)), $(".tabnav_2").mouseenter(function() {
		$(this).parent().addClass("tabhover")
	}).mouseleave(function() {
		$(this).parent().removeClass("tabhover")
	})
})